$(function(){
	 var value = $('.Region option:selected').val();
	console.log(value)
	if(value == undefined){
		$('#District').hide();
	}
})

var district_Arr='';
$(document).ready(function(){
	district_Arr=JSON.parse(sessionStorage.getItem('district_Arr'));
	var Region_str='<option value="">-- Please Select Region --</option>';
	for(var i=0;i<district_Arr.length;i++){
		Region_str+='<option value="'+district_Arr[i].id+'">'+district_Arr[i].name+'</option>';
	}
	$('#Region').html(Region_str);

})

$('#Region').change(function () {
	$('#District').show();
	var Region_id=$(this).val();
	if (Region_id==""){
		$('#District').html('<option value="">-- Please Select District -- </option>');
	}
	var District_str='<option value="">-- Please Select District -- </option>';
	for(var i=0;i<district_Arr.length;i++){
		if (district_Arr[i].id == Region_id){
			var district=district_Arr[i].district;
			for(var j=0;j<district.length;j++){
				District_str+='<option value="'+district[j].id+'">'+district[j].name+'</option>';
			}
			$('#District').html(District_str);
			break;
		}
	}
})


$('.btnBox a.mui-btn').on('tap',function(){
	var arr={
		hf_s_id:"WD11",
		hf_srv_id:"Cv_jcus_address",
		hs_action_id:"insert",
		hs_addr_key:"1",
		hs_addr_name:$('#nikeName').val(),
		hs_addr_1:$('#floor').val(),
		hs_addr_2:$('#building').val(),
		hs_addr_3:$('#estate').val(),
		hs_addr_4:$('#street').val(),
		hs_district_id:$('#District').val(),
		hs_def_addr_ind:"Y",
		button:"Save"
	}
	getAjaxRequest(arr,function(result) {
		if(result.bs_result==BS_RESULT.OK){
			location.replace(document.referrer);
		}
	})
})


$('.checkBox').on('tap',function(){
	if($(this).hasClass('on')){
		$('.checkBox').removeClass('on');
	}else{
		$('.checkBox').addClass('on');
	}
})
